package com.tjakus.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.tjakus.logging.Logging;
import com.tjakus.parser.XMLManager;
import com.tjakus.userdata.UserDataList;

/**
 * This class represents Quartz job which is responsible for reading user data
 * from XML file.
 * 
 * @author tjakus
 * 
 */

public class ReadUserDataJob implements Job {

	/**
	 * This method is called when schedule trigger occurs. It is responsible to
	 * read user data from XML file.
	 * 
	 */
	public void execute(JobExecutionContext context) throws JobExecutionException {
		Logging.getLogger().info("ReadUserDataJob - execute [ STARTED ] ");
		
		// Read user data from XML file
		UserDataList.setUserDataList(XMLManager.getUserDataFromXmlFile("userdata.xml"));
		
		if (UserDataList.getUserDataList() == null) {
			Logging.getLogger().error(
					"ReadUserDataJob - execute - [ Problem reading XML file ] ");
		}
		Logging.getLogger().info("ReadUserDataJob - execute [ FINISHED ] ");
	}
}